package com.hgm.flopgame2.adapter

import android.view.View
import android.view.ViewGroup
import androidx.viewpager.widget.PagerAdapter

class IntroductionAdapter(var pagerList: List<View>) : PagerAdapter() {


    //页数
    override fun getCount(): Int {
        return pagerList.size
    }

    //复用页卡
    override fun isViewFromObject(view: View, `object`: Any): Boolean {
        return view == `object`
    }

    //生成页卡
    override fun instantiateItem(container: ViewGroup, position: Int): View {
        val view = pagerList[position]
        container.addView(view)
        return view
    }

    //销毁页卡
    override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
        container.removeView(pagerList[position])
    }
}